#include<bits/stdc++.h>
//#define int long long
#define endl '\n'
using namespace std;
const int mod=998244353,inf=0x3f3f3f3f;
const int N=5e5+10,M=2e5+10;
int n,K;
const int LG=20;
pair<int,int>st[LG+10][N];
int a[N];
void init()
{
	for ( int i = 1 ; i <= n ; i++ )
		st[0][i]={a[i],i};
	for ( int i = 1 ; i <= LG ; i++ )
	{
		for ( int j = 1 ; j+(1<<i)-1 <= n  ; j++ )
			st[i][j]=min(st[i-1][j],st[i-1][j+(1ll<<i-1)]);
	}
}
inline pair<int,int>query(int l,int r)
{
	if(r<l)return {inf,inf};
	int lg=log2(r-l+1);
	return min(st[lg][l],st[lg][r-(1ll<<lg)+1]);
}
inline int solve(int l,int r,int lim)
{
	if(l==0)l=n;
	if(l==n+1)l=1;
	if(r==n+1)r=1;
	if(r==0)r=n;
//	cerr << "solve" << l << " " << r << endl;
//	assert(1<=l&&l<=n);
//	assert(1<=r&&r<=n);
	if(l<=r)
	{
		if(r-l+1==n)return 0;
		auto v=query(l,r);
		if(v.first+a[l-1]<=lim&&v.first+a[r+1]<=lim)
			return solve(l,v.second-1,lim)+solve(v.second+1,r,lim)+1;
		return 0;
	}
	auto v=min(query(l,n),query(1,r));
//	cerr << (r-l+1+n==n) << endl;
	if(r+n-l+1==n)return 0;
	if(v.first+a[l-1]<=lim&&v.first+a[r+1]<=lim)
		return solve(l,v.second-1,lim)+solve(v.second+1,r,lim)+1;
	return 0;
}
signed main()
{
	ios::sync_with_stdio(false);
	cin.tie(0),cout.tie(0);
	freopen("sub.in","r",stdin);
	freopen("sub.out","w",stdout);
	cin >> n >> K;
	for ( int i = 1 ; i <= n ; i++ )cin >> a[i];
	a[0]=a[n];a[n+1]=a[1];
	init();
	int min1=query(1,n).second;
	int min2=min(query(1,min1-1),query(min1+1,n)).second;
	if(min1>min2)swap(min1,min2);
//	cerr << min1 << " " << min2 << endl;
//	cerr << solve(min1+1,min2-1,1e3)+solve(min2+1,min1-1,1e3)+2 << endl;
	int l=0,r=2e9;
	while(l<r)
	{
		int mid=(l+r)/2;
		if(solve(min1+1,min2-1,mid)+solve(min2+1,min1-1,mid)+2>=K)r=mid;
		else l=mid+1;
	}
	cout <<l  << endl;
	return 0;
}


